package cn.tedu.shoot;
import java.awt.image.BufferedImage;
import java.util.Objects;
import javax.imageio.ImageIO;

public class Images {
    public static BufferedImage sky;      //天空图片
    public static BufferedImage bullet;   //子弹图片
    public static BufferedImage[] heros;  //英雄机图片数组
    public static BufferedImage[] airs;   //小敌机图片数组
    public static BufferedImage[] bairs;  //大敌机图片数组
    public static BufferedImage[] bees;   //小蜜蜂图片数组
    public static BufferedImage pause;    //暂停
    public static BufferedImage gameover; //结束
    public static BufferedImage gameover_1; //结束

    public static BufferedImage player;   //玩家


    /* 图片静态块*/
    static {

        sky      = readImage("./img/background.png");//天空
        sky      = readImage("./img/background.png");//天空
        bullet   = readImage("./img/bullet.png");    //子弹


        pause    = readImage("./img/pause.png");     //暂停
        gameover = readImage("./img/gameover.png");  //游戏结束
        gameover = readImage("./img/gameover_1.png");  //游戏结束

        player   = readImage("./img/fxl.png");       //玩家

        heros    = new BufferedImage[2]; //2张图片
        heros[0] = readImage("./img/hero0.png");
        heros[1] = readImage("./img/hero1.png");

        airs     = new BufferedImage[5]; //5张图片
        bairs    = new BufferedImage[5]; //5张图片
        bees     = new BufferedImage[5]; //5张图片
        airs[0]  = readImage("./img/airplane.png");
        bairs[0] = readImage("./img/bigairplane.png");
        bees[0]  = readImage("./img/bee.png");
        for(int i=1;i<airs.length;i++){ //赋值爆破图
            airs[i]  = readImage("./img/bom"+i+".png");
            bairs[i] = readImage("./img/bom"+i+".png");
            bees[i]  = readImage("./img/bom"+i+".png");
        }

    }

    /**
     * 图片生成方法
     */
    public static BufferedImage readImage(String fileName){
        try{
            return ImageIO.read(Objects.requireNonNull(FlyingObject.class.getResource(fileName)));
        }catch(Exception e){
            e.printStackTrace();
            throw new RuntimeException();
        }
    }
}
